<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        会员列表
    <#--<a id="refresh" class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>-->
    </nav>
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                <span class="l">共有数据：<strong><#if users??>${users?size}<#else>0</#if></strong> 条</span>
                <span class="r">
				    <a href="javascript:;" onclick="addUser()" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加用户</a>
				</span>
            </div>
            <div class="mt-20">
                <table class="table table-border table-bordered table-bg table-hover table-sort">
                    <thead>
                    <tr class="text-c">
                        <th width="80">用户名</th>
                        <th width="80">昵称</th>
                        <th width="50">级别</th>
                        <th>集群列表</th>
                        <th width="90">登录IP</th>
                        <th width="120">更新时间</th>
                        <th width="120">创建时间</th>
                        <th width="80">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#if users??>
                        <#list users as u>
                        <tr class="text-c">
                            <td>${u.name}</td>
                            <td>${u.nickName}</td>
                            <td><#if u.level??><#if u.level==0>超级管理员<#elseif u.level==1>管理员<#else>用户</#if></#if></td>
                            <td style="text-align:left;"><#if u.clusters??>${u.clusters}<#else ></#if></td>
                            <td><#if u.loginIp??>${u.loginIp}<#else ></#if></td>
                            <td><#if u.updateTime?exists>${u.updateTime?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
                            <td><#if u.createTime?exists>${u.createTime?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
                            <td class="td-manage">
                                <a title="编辑" href="javascript:;" onclick="editUserInfo('修改会员信息','/user/edit','${u.name}','500','450')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                                <a style="text-decoration:none" class="ml-5" onClick="editUserInfo('修改密码','/user/changePassword','${u.name}','600','270')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
                                <a title="删除" href="javascript:;" onclick="deleteUser('/user/delete','${u.name}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                            </td>
                        </tr>
                        </#list>
                    </#if>
                    </tbody>
                </table>
            </div>
        </article>
    </div>
</section>

<#include "../common/_footer.html">

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/resources/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/resources/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

    $('.table-sort').dataTable({
        "aaSorting": [[ 0, "asc" ]],//默认第几个排序
        "bStateSave": true,//状态保存
        "aoColumnDefs": [
            //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
            {"orderable":false,"aTargets":[7]}// 不参与排序的列
        ]
    });

    /* 删除-用户 */
    function deleteUser(url, name) {
        layer.confirm("确定要删除【"+name+"】吗？", {icon: 3, title:'提示'}, function () {
            var index = layer.load(2);
            $.ajax({
                url: url+"?name="+name,
                type: "GET",
                success: function (result) {
                    layer.close(index);
                    if (result.code === 0) {
                        layer.msg("删除成功", {icon:6,time:1000},
                                function () {location.reload();}
                        );
                    } else {
                        layer.alert("删除失败", {icon:5,time:1000},null);
                    }
                },
                error: function (result) {
                    layer.close(index);
                    layer.msg("内部错误", {icon:5,time:2000},null);
                }
            });
        }, function (flag) {
            flag = false;
        });
    }

    /* 添加-用户 */
    function addUser(title, url, name, w, h) {
        var title = "添加用户";
        var url = "/user/addUser";
        layer_show(title, url, 450, 550);
    }

    /* 修改-用户 */
    function editUserInfo(title,url,name,w,h){
        var path = url+"?name="+name;
        layer_show(title,path,w,h);
    }

    /* 查找资源 */
    function doSubmit() {
        $("#myForm").submit();
    }
</script>
